package controlGraph;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Administrator
 * This object is maintained for every variable
 */
public class AxiomArray {
	
	private List<Axiom> axiomArray;
	
	public AxiomArray(){
		this.axiomArray = new ArrayList<Axiom>();
	}
	
	/**
	 * @param a - Adds the axiom to the Arraylist of Axioms
	 */
	public void addAxiom(Axiom a){
		this.axiomArray.add(a);
	}
	
	/**
	 * @param a - This is the LValue which is being checked for its presence in the whole of the Axiom list
	 * @return - Returns all the Axioms which contain axioms related to a particular variable
	 */
	
	//Not Required
	/*public List<Axiom> isExpressionPresent(Expression a){
		List<Axiom> ret = new ArrayList<Axiom> ();
		
		Iterator<Axiom> it = this.axiomArray.iterator();
		while(it.hasNext()){
			Axiom curr = it.next();
			if((curr.getRightExp().toString()).equals(a.toString()) || (curr.getLeftExp().toString()).equals(a.toString())){
				ret.add(curr);
			}
		}
		if((this.toString()).equals(a.toString())){
			
		}
		return ret;
	}*/

	/**
	 * @param remove - This is the LValue that has to be removed when there is assignment
	 */
	public void removeAxiom(Expression remove){
		List<Axiom> newCre = new ArrayList<Axiom>();
		Iterator<Axiom> it = this.axiomArray.iterator();
		while(it.hasNext()){
			Axiom curr = it.next();
			if(!(curr.getRightExp().toString().equals(remove.toString()))){
				newCre.add(curr);
			}
		}
		this.axiomArray = new ArrayList<Axiom>(newCre);
	}
}
